package opengl.program;

public class D2GLProgram extends GLProgram {

	protected final static String BASE_VERT_SHADER_FILE_NAME = "..\\shader\\D2Vert.glsl";
	protected final static String BASE_FRAG_SHADER_FILE_NAME = "..\\shader\\D2Frag.glsl";


	protected final static String TEXTURE_NAME = "texture_diffuse";

	protected final static String INPUT_POSITION_NAME = "in_Position";
	protected final static String INPUT_COLOR_NAME = "in_Color";
	protected final static String INNUT_TEXTURECOORD_NAME = "in_TextureCoord";

	// fragment shader
	protected int textureUniform;

	protected int positionIndex;
	protected int colorIndex;
	protected int textureCoordIndex;

	public D2GLProgram() {
		super();
	}

	public void init() throws Exception {
		initShaders();
		getAttribLocationes();
	}

	protected void initShaders() throws Exception {
		int vs = GLShader.createVertexShader(this, BASE_VERT_SHADER_FILE_NAME);
		int fs = GLShader.createFragmentShader(this, BASE_FRAG_SHADER_FILE_NAME);
		super.initShaders(vs, fs);
	}

	protected void getAttribLocationes() {
		positionIndex = getAttribLocation(INPUT_POSITION_NAME);
		colorIndex = getAttribLocation(INPUT_COLOR_NAME);
		textureCoordIndex = getAttribLocation(INNUT_TEXTURECOORD_NAME);
	}

	public int getTextureUniform() {
		return textureUniform;
	}

	public int getPositionIndex() {
		return positionIndex;
	}

	public int getColorIndex() {
		return colorIndex;
	}

	public int getTextureCoordIndex() {
		return textureCoordIndex;
	}
}